﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CRUD;

namespace ClientASP
{
    public partial class _Default : System.Web.UI.Page
    {
        string path = @"NET*c:\temp\MyTestku.csv";
        static MyList list;
        edit p = new edit();
        public Person CurrentPerrson { get; set; }

        private void Delete_B_Click(object sender, EventArgs e)
        {
            Person a = null;
            foreach (Person pp in list)
            {
                if (pp.id == Convert.ToInt32(Id_TB.Text))
                {
                    a = pp;
                }
            }
            Response.Redirect("edit.aspx");

        }
         private void Read_B_Click(object sender, EventArgs e)
          {
              ip.read();
          }
          private void Create_b_Click(object sender, EventArgs e)
          {
              Person a = null;           
              secF.curper = a;
              secF.ShowThis();
              Hide();
          }
          
        protected void Page_Load(object sender, EventArgs e)
        {
            list = Factory.gi(path).Read();            
            Person_G.DataSource = list;
            Person_G.DataBind();           
        }

        protected void Del_b_Click(object sender, EventArgs e)
        {
            list.delete(path, Convert.ToInt32(Id_TB.Text));
        }
        protected void Up_B_Click(object sender, EventArgs e)
        {
            int a=0;
            foreach (Person pp in list)
            {
                if (pp.id == Convert.ToInt32(Id_TB.Text))
                {
                    a = pp.id;
                    CurrentPerrson = pp;
                }                
            }
            Server.Transfer("edit.aspx",true);
          // Response.Redirect("edit.aspx");            
        }
    }
}
